<?php


ini_set('memory_limit', '4G');
ini_set('default_socket_timeout', -1);
//1.写部分数据和写全部数据,性能会有差别吗? 会
//2.文件锁是系统级别的,测试不同进程争抢的结果.
//3.打开文件资源;创建(拷贝)文件;修改(删除)文件;文件属性;文件资源指针操作;文件资源读;文件资源写;文件锁;




$file = "/data/logs/words.log";
$file2 = "/data/logs/words2.log";
$file3 = "/data/logs/words_all.log";


$writeInstance = new CFileSystem($file, 'r+');
$writeInstance2 = new CFileSystem($file2, 'r+');
$writeInstance3 = new CFileSystem($file3, 'c+');

$experiment = new CoreExperiment(true);

$c1 = $writeInstance->read();
$c2 = $writeInstance2->read();

$arr1 = explode("\n", $c1);
$arr2 = explode("\n", $c2);

$map = [];
foreach ($arr2 as $v) {
    if (empty($v)) continue;
    list($word, $explain) = explode("|||", $v);
    $map[$word] = $explain;
}
foreach ($arr1 as $v) {
    if (empty($v)) continue;
    list($word, $explain) = explode("|||", $v);
    if (!isset($map[$word])) echo $word, PHP_EOL;
    $map[$word] = $map[$word] . '$$$' . $explain;
}
//$experiment->record();
//$c = '[我是谁]';
//foreach ($map as $key => $explain) {
//    $c .= implode('|||', [$key, $explain]) . PHP_EOL;
//}
//$writeInstance3->fseek(20)->write($c);
//exit;

//var_dump($instance->read($file));
//$instance->write($file, "abcdefghijklmnopqrstuvwxyz");
//$content = $instance->read();
//var_dump($content);
//$experiment->efficiency([$instance, 'scan'], ['opendir'], 1);
//$experiment->efficiency([$instance, 'read'], ['fread'], 1);






exit("\nend\n");
